package com.ysl.study.designpattern.createmode.simplefactory;

import com.ysl.study.designpattern.createmode.abstractfactory.AbstractFactory;

/**
 * 形状工厂
 *
 * @author yangshanlin
 * @date 2023/2/17 14:33
 * @describe
 */
public class ShapeFactory extends AbstractFactory {

    /**
     * 简单工厂
     * @param type
     * @return
     */
    public Shape getShape(String type){
        Shape shape = null;
        if (type.equals("circle")){
            shape = new Circle();
        } else if (type.equals("square")){
            shape = new Square();
        }
        return shape;
    }

    /**
     * 抽象工厂
     * @param type
     * @return
     */
    @Override
    public Shape getShapeFactory(String type) {
        return getShape(type);
    }

    @Override
    public Color getColorFactory(String type) {
        return null;
    }
}
